﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace chesslibrary.cs
{
    public class properties_table :base_table
    {
        public properties_table()
		{
		}
        public void Add(properties_cell s)
		{
			System.Diagnostics.Debug.Assert(Count<=64);
			base.Add(Key(s.Row,s.Col),s);
		}
        public void Remove(properties_cell s)
        {
            base.Remove(Key(s));
        }
		private string Key(properties_cell s)
		{
			return "" + s.Row + s.Col;
		}
        private string Key(int row,int col)
		{
			return "" + row + col;
		}
        public void Clear()
		{
			base.ClearTable();
		}
        public properties_cell this[int row,int col]
		{
			get
			{
				if (Contains(Key(row,col)))
					return (properties_cell)base.Get(Key(row,col));
				else	
					return null;
			}
		}
        public properties_cell this[cell_chess c]
		{
			get{return (properties_cell)base.Get(Key(c.Row,c.Col));}
		}
        public properties_cell this[string s]
		{
			get
			{
				s=s.ToUpper();
				char c=char.Parse(s.Substring(0,1));
				int row=int.Parse(s.Substring(1,1));
				return (properties_cell)base.Get(Key(row, (c-64)));
			}
		}
    }
}
